package com.leetcode.problems027;


/**
 * https://leetcode-cn.com/problems/merge-two-sorted-lists/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution {

    public int removeElement(int[] nums,int val) {
        if(nums == null || nums.length == 0){
            return 0;
        }
        int j = -1;
        for (int i = 0; i < nums.length; i++) {
            if( nums[i] != val)
                nums[++j] = nums[i];
        }

        return j + 1;
    }


    public static void main(String[] args) {
        int[] arr = {1,2,2,2,3};
        System.out.println(new Solution().removeElement(arr,1));
    }
}
